package com.easy;

/**
 * Created by Lxk on 2020/2/13.
 */
public class Solution242 {

    public boolean isAnagram(String s, String t) {
        int[] chCount = new int[26];
        for (int i = 0; i < s.length(); i++) {
            chCount[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            chCount[t.charAt(i) - 'a']--;
        }
        for (int i = 0; i < 26; i++) {
            if (chCount[i] != 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        String str = "rat";
        String str2 = "cat";
        Solution242 solution242 = new Solution242();
        System.out.println(solution242.isAnagram(str, str2));
    }

}
